/*
 * @LastEditTime: 2023-04-15 18:52:39
 */
export const isExistsforId = async (id: string, aim: any): Promise<boolean> => {
  try {
    const res: number = await aim.find({ _id: id }).count();
    if (res === 0) {
      return false;
    }
    return true;
  } catch (error) {
    return false;
  }
};
export const isExistsforTitle = async (
  title: string,
  aim: any
): Promise<boolean> => {
  try {
    const res = await aim.find({ name: title }).count();

    if (res === 0) {
      return false;
    }

    return true;
  } catch (error) {
    return false;
  }
};

export const isExistsforUsername = async (
  username: string,
  aim: any
): Promise<boolean> => {
  try {
    const res = await aim.find({ username: username }).count();
    if (res === 0) {
      // console.log("true");
      return true;
    }
    return false;
  } catch (error) {
    return false;
  }
};
